//
//  ThirdView.m
//  lovergotest
//
//  Created by liudonghuan on 14-8-12.
//  Copyright (c) 2014年 liudonghuan. All rights reserved.
//

#import "LGUtil.h"
#import "UserView.h"
#import "LXActionSheet.h"

@implementation UserView

@synthesize hImgView = _hImgView;
@synthesize uNameLab = _uNameLab;
@synthesize meTView = _meTView;
@synthesize delgete = _delegate;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UIScrollView *_scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        _scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, 508);
        _scrollView.backgroundColor = LGCOLOR_gray;
        _scrollView.showsHorizontalScrollIndicator = NO;
        _scrollView.showsVerticalScrollIndicator = NO;
        
        UIImageView *_hBgImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0 , SCREEN_WIDTH, 210)];
        [_hBgImgView setImage:[UIImage imageNamed:@"usercenterBGnew.png"]];
        
        UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(changeHeadImg:)];
        
        
        _hImgView = [[EMAsyncImageView alloc] initWithFrame:CGRectMake(100, 10, 120, 120) cornerRadius:60];
        _hImgView.userInteractionEnabled = YES;
        _hImgView.userInteractionEnabled = YES;
        [_hImgView addGestureRecognizer:tgr];
        _iconUImgView = [[UIImageView alloc]initWithFrame:CGRectMake(120, 125, 15, 15)];
        [_iconUImgView setImage:[UIImage imageNamed:@"usercenter_ico_boy.png"]];
        
        _uNameLab = [[UILabel alloc]initWithFrame:CGRectMake(140, 125, 120, 15)];
        [_uNameLab setTextColor:[UIColor whiteColor]];
        UIButton *_loginBtn = [LGUtil get9ScalBtn:CGRectMake(60, 380, 200, 44) type:TypeColorOrange];
        

        [_loginBtn setTitle:@"退出登陆" forState:UIControlStateNormal];
        [_loginBtn addTarget:self action:@selector(signOutBtnClieck) forControlEvents:UIControlEventTouchUpInside];
        _meTView = [[UITableView alloc]initWithFrame:CGRectMake(0, 200, SCREEN_WIDTH, 160)];
        _meTView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
        [_meTView setDirectionalLockEnabled:YES];
        _meTView.separatorStyle = UITableViewCellSeparatorStyleNone;
        //个人中心和订单的2个透明按钮
        _userInfoBtn = [[UIButton alloc]initWithFrame:CGRectMake(40, 161, 115, 30)];
        _dingdanBtn = [[UIButton alloc]initWithFrame:CGRectMake(170, 161, 115, 30)];
        [_userInfoBtn addTarget:self action:@selector(userinfoclick) forControlEvents:UIControlEventTouchUpInside];
        [_dingdanBtn addTarget:self action:@selector(dingdanclick) forControlEvents:UIControlEventTouchUpInside];
        
        [_scrollView addSubview:_hImgView];
        [_scrollView addSubview:_hBgImgView];
        [_scrollView addSubview:_iconUImgView];
        [_scrollView addSubview:_uNameLab];
        [_scrollView addSubview:_meTView];
        [_scrollView addSubview:_loginBtn];
        [_scrollView addSubview:_userInfoBtn];
        [_scrollView addSubview:_dingdanBtn];
        [self addSubview:_scrollView];
    
    }
    return self;
}
-(void)userinfoclick
{
    [_delegate gerenxinxiBtnClick];
}
-(void)dingdanclick
{
    [_delegate dingdanBtnClick];
}
-(void)changeHeadImg:(id)sender
{
    [_delegate UserViewBtnClieck:TypeChangeImg];
}
-(void)signOutBtnClieck
{
    [_delegate UserViewBtnClieck:TypeLogOut];
}



@end
